package com.qumitech.visualnovel.controller.rest;

import com.qumitech.visualnovel.component.thirdapi.aliyun.AliYunOSSUtil;
import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.google.common.collect.ImmutableMap;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import org.slf4j.Logger;


@RestController
@RequestMapping(value = "/api/common")
class CommonController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @RequestMapping(value = "/oss/token", method = RequestMethod.GET)
    public BaseRsp getToken(@RequestParam("type") String type) {
        Map policyMap = AliYunOSSUtil.getToken();
        return new BaseRsp(ResultEnum.SUCCESS, ImmutableMap.of("policy", policyMap));
    }

    @RequestMapping(value = "/oss/callback", method = RequestMethod.POST)
    public BaseRsp callback(HttpServletRequest request) {
        return new BaseRsp(ResultEnum.SUCCESS);
    }

}
